<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/connopen.asp"-->
<!--#include file="lib/asp-common-lib.asp"-->
<!--#include file="lib/js-jquery-lib.asp"-->
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>报关单登记系统</title>
<style type="text/css">
  .base{
    padding:8px;
  }
  .baseCenter{
    left:50%;
    margin-left:-10.5cm;
    width:21.3cm;
    position:relative;
  }
  .baseBlock{
    left:50%;
    margin-left:-10.5cm;
      width:21.4cm;
      position:relative;
  }
  .baseBlockIn{
      padding:0.5cm 0.2cm;
      background:#fff;
      box-shadow:0 0 8px #000;
      -moz-box-shadow:0 0 8px #000;
      -webkit-box-shadow:0 0 8px #000;
      position:relative;
      z-index:1;
  }
  .down{
    float:right;
    margin-left:10px;
  }
</style>
<!--[if IE]>
<style type="text/css">
  .baseBlockIn{
    top:8px;
    left:8px;
  }
  .ieShadow{
    filter:progid:DXImageTransform.Microsoft.Blur(pixelradius=8);
    -ms-filter:"progid:DXImageTransform.Microsoft.Blur(pixelradius=8)";
    background-color:#000;
    position:relative;
  }
</style>
<![endif]-->

<!--#include file="lib/js-google-analytics.asp"-->


</head>
<body>
<%
' for each x in Request.ServerVariables
' response.write(x &":"&Request.ServerVariables(x)& "<br />")
' next

' 对于采用内网映射过的端口检测到的是内网的端口，而不是映射过的，所以不管用
' SERVER_NAME=Request.ServerVariables("SERVER_NAME")
' SERVER_PORT=Request.ServerVariables("SERVER_PORT")

' select case SERVER_PORT
    ' case "55555"
        ' SERVER_PORT="50004"
    ' case "12996"
        ' SERVER_PORT="12995"
    ' case else
        ' SERVER_PORT="80"
' end select
' response.write("<input id='server_addr' type='hidden' value='"&SERVER_NAME&":"&SERVER_PORT&"'>")

SERVER_NAME=Request.ServerVariables("SERVER_NAME")
SERVER_PORT=Request.ServerVariables("SERVER_PORT")

select case SERVER_NAME
    case "122.227.172.219"
        SERVER_PORT="50004"
    case "nbzps.nat123.net"
        SERVER_PORT="12995"
    case else
        SERVER_PORT="80"
end select
response.write("<input id='server_addr' type='hidden' value='"&SERVER_NAME&":"&SERVER_PORT&"'>")


%>
<div class="cdframe">
<%
id=saferequest("id",1)
rcd=saferequest("rcd",0)
dtype=saferequest("dtype",0)
if rcd<>"null" then 
    if not CheckFlag(session("aaPostFlag"),2) then call JumpErrorPage(2)
end if
set rs=Server.CreateObject("ADODB.Recordset")
sql="select cd_no from cd where id="&id
if rcd<>"null" then
    if CheckWtr() then sql=sql&" and wtr="&session("iWtr")
end if
' response.write(sql)
rs.open sql,conn,1,1
if not rs.eof then
    if rcd="null" then
        if dtype="tz" then
            call SimpleRecord("tzhtml",id,"查看","成功","null",OperateClient("null"),false)
        else
            call SimpleRecord("htmlfile",id,"查看","成功","null",OperateClient("null"),false)
        end if
    elseif rcd<>"no" then
        if dtype="tz" then
            call SimpleRecord("tzhtml",id,"查看","成功",session("iId"),session("iClientId"),false)
        else
            call SimpleRecord("htmlfile",id,"查看","成功",session("iId"),session("iClientId"),false)
        end if
    end if
    
    ' call ShowFile(rs("cd_no"))
    
    response.write("<input id='cd_no' type='hidden' value='"&rs("cd_no")&"' />")
    response.write("<input id='dtype' type='hidden' value='"&dtype&"' />")
    response.write("<div></div>")
    ' Response.Write("<div class='base'><div class='baseCenter'><a href='pdffile.asp?id="&id&"&rcd="&rcd&"'>下载</a></div></div>")

    
else
    if rcd="null" then
        if dtype="tz" then
            call SimpleRecord("tzhtml",id,"查看","失败","null",OperateClient("null"),false)
        else
            call SimpleRecord("htmlfile",id,"查看","失败","null",OperateClient("null"),false)
        end if
    elseif rcd<>"no" then
        if dtype="tz" then
            call SimpleRecord("tzhtml",id,"查看","失败",session("iId"),session("iClientId"),false)
        else
            call SimpleRecord("htmlfile",id,"查看","失败",session("iId"),session("iClientId"),false)
        end if
    end if
    call JumpErrorPage(2)
end if
rs.close
set rs=nothing

function ShowFile(cd_no)
  dim sign,fs,cd_file
  sign=1
  Set fs=Server.CreateObject("Scripting.FileSystemObject")
  cd_file=Server.MapPath(".")&"\file\html\"&cd_no&"."&sign&".html"
  ' cd_box=Server.MapPath(".")&"\file\"&cd_no&".box.html"
  ' Response.Write(cd_file)
  If Not fs.FileExists(cd_file) then
    Response.Write("原始报关单未保存在系统中")
  else
      Response.Write("<div class='base'><div class='baseCenter'><a href='pdffile.asp?id="&id&"&rcd="&rcd&"'>转到PDF版</a>&nbsp;&nbsp;&nbsp;<a href='file/pdf/"&cd_no&".pdf'>下载完整PDF文件</a></div></div>")
      Do While fs.FileExists(cd_file)
        Response.Write("<div class='base'><div class='baseBlock'><div class='ieShadow'><div class='baseBlockIn'><iframe frameborder='0' scrolling='auto' width='100%' height='1123' src='file/html/"&cd_no&"."&sign&".html"&"'></iframe></div></div></div></div>")
        sign=sign+1
        cd_file=Server.MapPath(".")&"\file\html\"&cd_no&"."&sign&".html"
      Loop
      ' If fs.FileExists(cd_box) then Response.Write("<div class='base'><div class='baseBlock'><div class='ieShadow'><div class='baseBlockIn'><iframe frameborder='0' scrolling='auto' width='100%' height='1123' src='file/"&cd_no&".box.html"&"'></iframe></div></div></div></div>")
  end if
  set fs=nothing
end function
%>
</div>

<script type="text/javascript">
  $(function() {
    var dtype=$("#dtype").val();
    var url="http://"+$("#server_addr").val()+"/gethtmlfile?callback=?";
    $.getJSON(url,{entry_id:$("#cd_no").val(),id:<%=cop.item("copid")%>,document_type:dtype},function(json){
        //console.log(json["cd_no"]);
        entry_id=json["cd_no"];
        $.each(json.htmlcd, function(i,item){
            //console.log(i);
            //console.log(item);
            //console.log(item[entry_id+"."+(i+1)+".html"]);
            $iframe=$("<div class='base'><div class='baseCenter'>第 "+(i+1)+" 页<span class='down'>报关单号：<a class='down' href='http://"+$("#server_addr").val()+"/gethtmlfile?id=<%=cop.item("copid")%>&document_type="+dtype+"&download=True&entry_id="+entry_id+"&page="+i+"&format=html&filename_type=cd_no'>WEB下载</a><a class='down' href='http://"+$("#server_addr").val()+"/gethtmlfile?id=<%=cop.item("copid")%>&document_type="+dtype+"&download=True&entry_id="+entry_id+"&page="+i+"&format=pdf&filename_type=cd_no'>PDF下载</a></span><span class='down'>提单号：<a class='down' href='http://"+$("#server_addr").val()+"/gethtmlfile?id=<%=cop.item("copid")%>&document_type="+dtype+"&download=True&entry_id="+entry_id+"&page="+i+"&format=html&filename_type=cd_lading'>WEB下载</a><a class='down' href='http://"+$("#server_addr").val()+"/gethtmlfile?id=<%=cop.item("copid")%>&document_type="+dtype+"&download=True&entry_id="+entry_id+"&page="+i+"&format=pdf&filename_type=cd_lading'>PDF下载</a></span></div></div><div class='base'><div class='baseBlock'><div class='ieShadow'><div class='baseBlockIn'><iframe id='iframe"+(i+1)+"' frameborder='0' scrolling='auto' width='100%' height='1123' src='about:blank'></iframe></div></div></div></div>");
            //console.log($iframe);
            $(".cdframe").append($iframe);
            
            //$("#page"+i).on("click",function(event){
            //    event.preventDefault();
            //    console.log($(this).text());
            //    window.open("http://localhost:50004/gethtmlfile?download=True&entry_id="+entry_id+"&page="+i+"&format=html");
            //});
            
            
            var d = $("#iframe"+(i+1))[0].contentWindow.document; // contentWindow works in IE7 and FF
            d.open(); d.close(); // must open and close document object to start using it!

            // now start doing normal jQuery:
            if(dtype=="tz"){
                $("body", d).append(item[entry_id+".html"]);
            
            }else{
                $("body", d).append(item[entry_id+"."+(i+1)+".html"]);
            }
        });
    });
  
  });
</script>



</body>
</html>
<!--#include file="lib/connclose.asp"-->

